package com.lordjoe.collectiveintelligence;

/**
 * com.lordjoe.collectiveintelligence.FlightCost
 *
 * @author Steve Lewis
 * @date Mar 24, 2009
 */
public class ItineryItemCost implements ICostFunction<ItineryItem>
{
    public static ItineryItemCost[] EMPTY_ARRAY = {};
    public static Class THIS_CLASS = ItineryItemCost.class;

    public static final ItineryItemCost INSTANCE = new  ItineryItemCost();

    public static final double DOLLAR_COST_FACTOR = 1.0;
    public static final double MINUTE_WAIT_COST_FACTOR = 0.1;

    private ItineryItemCost() {}

    public double computeCost(ItineryItem target, Object... otherData)
    {
        ItineryItem[] allFlights = (ItineryItem[])otherData;
        double sum = 0;
        sum += DOLLAR_COST_FACTOR * target.getArrival().getCost();
        sum += DOLLAR_COST_FACTOR * target.getReturn().getCost();

        sum += MINUTE_WAIT_COST_FACTOR +
                OptimizationUtilities.arrivalWait(target,allFlights );
        sum += MINUTE_WAIT_COST_FACTOR +
                OptimizationUtilities.departWait(target,allFlights );

         return sum;
    }

    public double lowestCost()
    {
        return 0;
    }
}
